package com.example.hoasbackend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.hoasbackend.mapper.RoomTypeMapper;
import com.example.hoasbackend.model.AO.HotelAO;
import com.example.hoasbackend.model.VO.HotelInfoVO;
import com.example.hoasbackend.model.domain.Hotel;
import com.example.hoasbackend.mapper.HotelMapper;
import com.example.hoasbackend.model.domain.RoomType;
import com.example.hoasbackend.service.HotelService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lhx
 * @since 2022-03-03
 */
@Service
public class HotelServiceImpl extends ServiceImpl<HotelMapper, Hotel> implements HotelService {

    @Autowired
    HotelMapper hotelMapper;

    @Autowired
    RoomTypeMapper roomTypeMapper;

    @Override
    public List<HotelInfoVO> listByMultipleConditions(HotelAO hotelAO) {
        return hotelMapper.selectByMultipleConditions(hotelAO);
    }

    @Override
    public List<HotelInfoVO> listByPosition(Double lat, Double lng) {
        return hotelMapper.selectByPosition(lat,lng);
    }

    @Override
    public List<RoomType> listAllRoom(Long id) {
        QueryWrapper<RoomType> wrapper=new QueryWrapper<RoomType>()
                .eq("hotel_id",id);
        return roomTypeMapper.selectList(wrapper);
    }

    @Override
    public HotelInfoVO getHotelVOById(Long id) {
        return hotelMapper.selectHotelVoById(id);
    }
}
